package question3;

import java.util.ArrayList;
import java.util.List;

public class Department {
    private String name;
    private School school; // 所属学院
    private List<Instructor> instructors = new ArrayList<>();
    private List<Subject> subjects = new ArrayList<>();

    // 构造时关联学院
    public Department(String name, School school) {
        this.name = name;
        this.school = school;
        school.addDepartment(this); // 反向关联学院
    }

    public void setSchool(School school) {
        this.school = school;
    }

    // 添加指导教师
    public void addInstructor(Instructor instructor) {
        instructors.add(instructor);
        instructor.setDepartment(this);     // 反向关联教师
    }

    // 添加课程
    public void addSubject(Subject subject) {
        subjects.add(subject);
        subject.setDepartment(this);    // 反向关联课程
    }
}
